Skip to content

feat(tg-11): surface syntax for epistemic types + fix a second statement-order bug - #99

Merged
hyperpolymath merged 1 commit into
mainfrom
feat/epistemic-surface-syntax
Jul 29, 2026
Merged

feat(tg-11): surface syntax for epistemic types + fix a second statement-order bug#99
hyperpolymath merged 1 commit into
mainfrom
feat/epistemic-surface-syntax

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

TG-11 (#98) landed the type former, typing, evaluation and six proofs — but there was no way to write one. Zero occurrences of the constructors in lexer.mll or parser.mly, against 4 for echo. Fully implemented and unreachable.

Surface syntax

def w     = warrant[0](42, braid[s1, s2])   -- at standpoint 0
def token = evidence(w)                      -- the ONLY elimination

The standpoint is bracketed because it's an index, not an operand — the same reading as a braid generator's subscript. No grammar conflicts.

Non-factivity reaches the syntax. There is deliberately no keyword extracting the claim: claim(w) parses as an ordinary call to an undefined function, never as a language form. A test pins that distinction — if a Claim form ever appears, it contradicts epi_only_yields_evidence.

A second copy of the statement-order bug

Writing the first epistemic program surfaced it immediately:

def w   = warrant[0](42, braid[s1])
def tok = evidence(w)
→ In definition 'tok': evidence requires an Epi[k, rho, tau], got Word[0]

That Word[0] is the pass-1a placeholdertok was being checked before w was refined. Same root cause as #95 (stmts := prog @ !stmts then List.rev on the flattened list), but in a second copy, in lib/check.ml.

That copy feeds tanglec --check and the LSP. Both have been analysing programs with their statements reversed.

And it was never epistemic-specific:

def e = echoClose(braid[s1])
def r = residue(e)
→ residue requires Echo[_, _], got Word[0]

Any cross-definition reference to a non-Word type was mis-typed. Echo has been broken this way for as long as the recovering path has existed.

The test suites missed both copies for the same reason: they call Parser.program directly and never exercise the recovering path.

Tests

Parser — warrant with bracketed standpoint; evidence; TG-4 round-trip; the no-claim-form guard.
Check — three cross-definition cases (plain, echo, epistemic), all of which would have failed before this.

Example

examples/epistemic.tangle, wired into the corpus gate's must-run set — warrants at three standpoints, evidence recovery, and the echo composition residue(evidence(we)). All assertions pass.

It also documents why the claim is unreachable: if it were extractable, anything anyone attested would become true by fiat — precisely the bug you don't want in a provenance system.

All gates green: Lean 0 errors, full suite, corpus, RSR.

🤖 Generated with Claude Code

…ent-order bug

TG-11 landed the type former, typing, evaluation and six proofs — but there
was no way to WRITE one. Zero occurrences of the constructors in lexer.mll or
parser.mly, against 4 for echo. Fully implemented and unreachable.

## Surface syntax

    warrant[k](claim, evidence)     -- at standpoint k
    evidence(w)                     -- the ONLY elimination

The standpoint is bracketed because it is an index, not an operand — the same
reading as a braid generator's subscript.

Non-factivity reaches the syntax too: there is deliberately NO keyword that
extracts the claim. `claim(w)` parses as an ordinary call to an undefined
function, never as a language form, and a test pins that distinction — if a
`Claim` form ever appears, it contradicts epi_only_yields_evidence.

No grammar conflicts.

## A SECOND copy of the statement-order bug

Writing the first epistemic program surfaced it. `def w = warrant[...]` then
`def tok = evidence(w)` failed with

    In definition 'tok': evidence requires an Epi[k, rho, tau], got Word[0]

The Word[0] is the pass-1a placeholder: `tok` was being checked BEFORE `w` had
been refined. Same root cause as #95 — `stmts := prog @ !stmts` followed by
`List.rev` on the flattened list — but in a SECOND copy, in lib/check.ml.

That copy feeds `tanglec --check` AND the LSP, so both have been analysing
programs with their statements reversed. It was not epistemic-specific:

    def e = echoClose(braid[s1])
    def r = residue(e)          -- "residue requires Echo[_, _], got Word[0]"

Any cross-definition reference to a non-Word type was mis-typed. Echo has been
broken this way for as long as the recovering path has existed. Fixed
identically: accumulate segments, flatten in order.

The test suites missed BOTH copies because they call Parser.program directly
and never exercise the recovering path.

## Tests

Parser: warrant with bracketed standpoint, evidence, TG-4 round-trip, and the
no-claim-form guard. Check: three cross-definition cases — plain, echo, and
epistemic — that would all have failed before.

examples/epistemic.tangle added and wired into the corpus gate's must-run set:
warrants at three standpoints, evidence recovery, and the echo composition
(`residue(evidence(we))`). All assertions pass.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@hyperpolymath
hyperpolymath merged commit 40e917d into main Jul 29, 2026
25 checks passed
@hyperpolymath
hyperpolymath deleted the feat/epistemic-surface-syntax branch July 29, 2026 06:28
@gitar-bot

gitar-bot Bot commented Jul 29, 2026

Copy link
Copy Markdown

Note

Automatic reviews are paused because your trial's included automatic processing has been used for this period. Upgrade now, or comment "Gitar review" to run a review anytime.
Learn more

Code Review ✅ Approved

Adds surface syntax for epistemic types and fixes a statement-order bug in the checker that caused cross-definition references to resolve placeholders. No issues found.

Auto-approved and auto-merge armed: No blocking issues found.
Please see Auto-approve Docs for details on setting custom approval criteria. — merges when pipeline and required approvals pass.

Options

Display: compact → Showing less information.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

@gitar-bot

gitar-bot Bot commented Jul 29, 2026

Copy link
Copy Markdown

⚠️ Gitar auto-approved this PR but could not enable auto-merge: auto-merge is disabled for this repository — enable "Allow auto-merge" in the repository settings.

@gitar-bot gitar-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gitar has auto-approved this PR and enabled auto-merge (configure)

@gitar-bot gitar-bot Bot added the gitar-approved Added by Gitar label Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gitar-approved Added by Gitar

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant